#ifndef DETECTIONDIALOG_H
#define DETECTIONDIALOG_H

#include <QDialog>
#include "viewwidget.h"
#include "SeatShowInfoDialog.h"
#include "myopenglwidget.h"
#include "historyinformation.h"

//#define IMAGE_COUNT 22
#define SEAT_COUNT 6

namespace Ui {
class DetectionDialog;
}

/**
 * @brief 这个对话框为实时运行检查对话框
 */

class DetectionDialog : public QDialog
{
    Q_OBJECT

public:
    explicit DetectionDialog(SeatDetectionParameter &seatDetectionParameter,
                             QWidget *parent = nullptr);
    ~DetectionDialog();

private:
    // 系统主要配置参数
    SeatDetectionParameter &m_seatDetectionParameter;
    // 驱动座椅3D模型的三个参数
    QVector3D angle, scale, pos;
    int number;
    QImage          m_imgNoImage;


private slots:
    void on_pushButtonDetectionExit_clicked();
    void on_pushButtonSwitchImage_clicked();

    void HasChangeSelect(int index);

    void on_pushButtonReset_clicked();

    void on_pushButtonDeviationRelease_clicked();

    void on_pushButtonIsolate_clicked();

    void on_pushButtonOnlineMaintenance_clicked();

public slots:
    // 接收到日志信息
    void ReceiveLogMessage(QString message);
    // 开始一个新的检测任务，清楚上一个座椅的检测结果
    void ClearImage();
    // 接收到一个新的检测结果数据，放在历史表格中
    void ReceiveNewHistoryInforamtion(QList<HISTORYINFORMATION*> his);
    // 用户选中一行
    // 连接itemSelectionChanged信号到槽函数
    void handleItemSelectionChanged();

signals: //使用signals声明信号函数，访问级别为protected
    void NewDetectionResultSignal(SeatDetectionParameter &seatDetectionParameter,
                                  DetectionResult &detectionResult);
    void sendSeatModelControlMessage(QVector3D angles, QVector3D scale, QVector3D viewPos);
    // 发送用户操作命令
    void sendButtonControlCmd(QString content);
    // 发送查询座椅
    void sendQuerySeat(QString seatNumber);

public:
    void SetDetectionResult(SeatDetectionParameter &seatDetectionParameter,
                            DetectionResult &detectionResult,bool isShow10X);

    void closeEvent(QCloseEvent *event) override;

private:
    Ui::DetectionDialog *ui;
    ViewWidget **m_ppImageViewWidgets;
    ViewWidget *seatViewWidgets[SEAT_COUNT];
    QStringList seatFilenames;

private:
    void InitImageViewWidget();
    void InitSeatViewWidget();
    void InitInformationWidget();
};

#endif // DETECTIONDIALOG_H
